﻿using System;
using UnityEngine;
using UnityEngine.Events;

namespace SillyCube.Level
{
    public class CubeCollisionTrigger : MonoBehaviour
    {
        [SerializeField] private UnityEvent onCollisionEnter;
        [SerializeField] private UnityEvent onCollisionStay;
        [SerializeField] private UnityEvent onCollisionExit;
        
        private void OnCollisionEnter2D(Collision2D other)
        {
            if (other.gameObject.CompareTag("Cube"))
            {
                onCollisionEnter.Invoke();
            }
        }

        private void OnCollisionStay2D(Collision2D other)
        {
            if (other.gameObject.CompareTag("Cube"))
            {
                onCollisionStay.Invoke();
            }
        }
        
        private void OnCollisionExit2D(Collision2D other)
        {
            if (other.gameObject.CompareTag("Cube"))
            {
                onCollisionExit.Invoke();
            }
        }
    }
}